package fr.generali.accueilclient.gwt.client.ui.components.block;

import java.util.Iterator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class Block extends Composite implements HasWidgets {

    private static BlockUiBinder uiBinder = GWT.create(BlockUiBinder.class);

    interface BlockUiBinder extends UiBinder<Widget, Block> {
    }

    public interface Resources extends ClientBundle {
        @Source({"components/block/block.css"})
        Style style();
        
        interface Style extends CssResource {
            String header();
            String headerLabel();
            String headerCell();
            String block();
            String toolbar();
            String content();
        }
    }
    
    @UiField
    protected Resources res;
    
    @UiField
    FlowPanel header;
    
    @UiField
    FlowPanel content;
    
    public Block() {
        initWidget(uiBinder.createAndBindUi(this));
        res.style().ensureInjected();
    }

    @Override
    public void add(Widget widget) {
        content.add(widget);
    }

    @Override
    public void clear() {
        content.clear();
    }

    @Override
    public Iterator<Widget> iterator() {
        return content.iterator();
    }

    @Override
    public boolean remove(Widget widget) {
        return content.remove(widget);
    }
}
